import { userLogin } from "./service/user"

// app.ts
App({
  globalData: {
    userInfo: {},
    isCleanCart: false
  },
  onLaunch() {
    wx.login({   
      success: async (data) => {
        console.log(data, 'data')
        const res = await userLogin(data.code)
        console.log(res)
        wx.setStorage({
          key: 'token',
          data: res.data.token
        })
        wx.setStorage({
          key: 'user',
          data: res.data.user
        })
        this.globalData.userInfo = res.data.user
      },
      fail: (err) => {
        console.log('err')
      },
      complete: (a) => {
        console.log('lsdfj')
      }
    }) 
  },
})